using System;
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Ccr.Core;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using Microsoft.Dss.ServiceModel.DsspServiceBase;
using W3C.Soap;
using System.Drawing;

namespace Robotics.ImageCapt
{
    /// <summary>
    /// ImageCapt contract class
    /// </summary>
    public sealed class Contract
    {
        /// <summary>
        /// DSS contract identifer for ImageCapt
        /// </summary>
        [DataMember]
        public const string Identifier = "http://schemas.tempuri.org/2010/09/imagecapt.html";
    }

    /// <summary>
    /// ImageCapt state
    /// </summary>
    [DataContract]
    public class ImageCaptState
    {
        /// <summary>
        /// Image Input Type : 0 -> Camera, 1 -> File
        /// </summary>
        [DataMember]
        public int ImgInputType;

        /// <summary>
        /// Filename to read image from
        /// </summary>
        [DataMember]
        public string ImgFileName;
    }

    /// <summary>
    /// ImageCapt main operations port
    /// </summary>
    [ServicePort]
    public class ImageCaptOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get, Subscribe, NotifyImageCapture>
    {
    }

    /// <summary>
    /// ImageCapt get operation
    /// </summary>
    public class Get : Get<GetRequestType, PortSet<ImageCaptState, Fault>>
    {
        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        public Get()
        {
        }

        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        /// <param name="body">the request message body</param>
        public Get(GetRequestType body)
            : base(body)
        {
        }

        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        /// <param name="body">the request message body</param>
        /// <param name="responsePort">the response port for the request</param>
        public Get(GetRequestType body, PortSet<ImageCaptState, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }

    /// <summary>
    /// Image Capture Notification Operation
    /// </summary>
    [DisplayName("ImageCapture done.")]
    [Description("Indicates that image capture is done.")]
    public class NotifyImageCapture : Update<CaptureResult, PortSet<DefaultUpdateResponseType, Fault>>
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public NotifyImageCapture()
        {
        }

        /// <summary>
        /// Constructor with CaptureResult
        /// </summary>
        public NotifyImageCapture(CaptureResult body)
            : base(body)
        {
        }
    }

    /// <summary>
    /// Image Capture Result
    /// </summary>
    [DataContract]
    public class CaptureResult
    {
        /// <summary>
        /// Capture Result
        /// </summary>
        [DataMember]
        [Description("The resulting Capture image data")]
        public Bitmap CaptureResImage;

        /// <summary>
        /// Constructor
        /// </summary>
        public CaptureResult()
        {
        }
        /// <summary>
        /// Constructor with Image Data Result (Bitmap)
        /// </summary>
        public CaptureResult(Bitmap result)
        {
            CaptureResImage = result;
        }
    }

    /// <summary>
    /// ImageCapt subscribe operation
    /// </summary>
    public class Subscribe : Subscribe<SubscribeRequestType, PortSet<SubscribeResponseType, Fault>>
    {
        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        public Subscribe()
        {
        }

        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        /// <param name="body">the request message body</param>
        public Subscribe(SubscribeRequestType body)
            : base(body)
        {
        }

        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        /// <param name="body">the request message body</param>
        /// <param name="responsePort">the response port for the request</param>
        public Subscribe(SubscribeRequestType body, PortSet<SubscribeResponseType, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }
}


